<template>
  <div class="app-container">
    <el-form
      ref="listFilterRef"
      :model="list.filter"
      inline
      class="list-filter"
    >
      <el-form-item prop="name">
        <el-input
          v-model="list.filter.name"
          placeholder="标签名称"
          clearable
        />
      </el-form-item>
      <el-form-item prop="status">
        <Status v-model="list.filter.status" />
      </el-form-item>
      <el-form-item>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>

    <div class="table-operation">
      <AuthButton @click="c" name="新增" />
      <el-pagination
        v-bind="elPaginationProps"
        :total="list.total"
        :currentPage.sync="list.filter.pageNo"
        :pageSize.sync="list.filter.pageSize"
      />
    </div>

    <el-table v-loading="list.loading" :data="list.data" v-bind="tableProp">
      <!-- <el-table-column prop="sort" label="序号" /> -->
      <el-table-column prop="sort" label="展示顺利" />
      <el-table-column prop="name" label="标签名称" />
      <el-table-column label="启用状态" width="80" align="center">
        <template slot-scope="{ row: { id, status } }">
          <KiPopSwitch
            v-bind="popSwitchProps(status)"
            @change="updateStatus({ id, status: status ^ 1 })"
          />
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding">
        <template slot-scope="{ row: rowData }">
          <auth-button @click="u(rowData)" name="编辑" />
          <auth-button @click="d(rowData)" name="删除" />
        </template>
      </el-table-column>
    </el-table>

    <KiFormDialog
      :show.sync="form.show"
      :title="formTitle"
      v-model="form.data"
      :submit="submitForm"
      :readonly="form.status === 'r'"
      ref="formRef"
      :loading="form.loading"
      width="70%"
    >
      <template #el-form>
        <el-form-item label="标签名称" prop="name" verify>
          <el-input
            v-model="form.data.name"
            maxlength="30"
            show-word-limit
            placeholder="请输入"
          />
        </el-form-item>
        <el-form-item label="展示顺序" prop="sort" verify>
          <Sort v-model="form.data.sort" />
        </el-form-item>
        <el-form-item label="所属地区" prop="areaCodeList" verify>
          <RegionSelect
            v-model="form.data.areaCodeList"
            :props="{ checkStrictly: true, multiple: true }"
            placeholder="请选择所属地区，可多选"
          />
        </el-form-item>
        <el-form-item label="选择活动" prop="sort" verify>
          <ActivitySpot
            v-if="form.show"
            v-model="form.data.contentId"
            :selecteList="form.data.contentName"
            :type="form.status"
          />
        </el-form-item>
      </template>
    </KiFormDialog>
  </div>
</template>

<script>
import pageMixin from "@/utils/pageMixin";
import useAdmateAdapter from "@/utils/useAdmateAdapter";
import ActivitySpot from './components/activity-spot'
export default {
  mixins: [pageMixin],
  components: { ActivitySpot },
  setup: () => useAdmateAdapter({
    urlPrefix: "one-travel-api/activity-label",
    // form: {
    //   data: {
    //   },
    // }
  }),
  data() {
    return {
    };
  },
  methods: {
  },
};
</script>

<style lang="scss" scoped></style>
